<script setup lang="ts">
import { useAppStore } from '@/stores/app'
import { NButton, NSpace, NDivider } from 'naive-ui'

const store = useAppStore()
</script>

<template>
  <div class="app-container">
    <header>
      <nav class="nav-container">
        <div class="logo">
          <router-link to="/" class="logo-link">
<!--            <img src="/images/logo.png" alt="OpenCangjie Logo" class="logo-image" />-->
            <h1>{{ store.organization.name }}</h1>
          </router-link>
        </div>
        <div class="mobile-menu-button" @click="store.toggleMobileMenu">
          <div class="hamburger" :class="{ 'is-active': store.mobileMenuOpen }">
            <span></span>
            <span></span>
            <span></span>
          </div>
        </div>
        <div class="nav-links" :class="{ 'mobile-active': store.mobileMenuOpen }">
          <template v-for="item in store.menu" :key="item.path">
            <router-link 
              v-if="!item.external" 
              :to="item.path" 
              @click="store.closeMobileMenu"
            >{{ item.name }}</router-link>
            <NButton 
              v-else 
              tag="a"
              :href="item.path" 
              target="_blank"
              text
              @click="store.closeMobileMenu"
            >{{ item.name }}</NButton>
          </template>
        </div>
      </nav>
      <div class="mobile-menu-overlay" v-if="store.mobileMenuOpen" @click="store.closeMobileMenu"></div>
    </header>

    <router-view></router-view>

    <footer>
      <div class="footer-content">
        <div class="footer-section">
          <h3>仓颉语言</h3>
          <p>下一代现代编程语言</p>
        </div>
        <div class="footer-section">
          <h3>资源</h3>
          <NSpace vertical>
            <template v-for="item in store.menu.filter(item => item.showInFooter)" :key="item.path">
              <router-link 
                v-if="!item.external" 
                :to="item.path"
              >{{ item.name }}</router-link>
              <NButton 
                v-else 
                text
                tag="a"
                :href="item.path" 
                target="_blank"
              >{{ item.name }}</NButton>
            </template>
            <NButton text tag="a" href="https://gitcode.com/OpenCangjieCommunity" target="_blank">GitCode</NButton>
          </NSpace>
        </div>
        <div class="footer-section">
          <h3>社区</h3>
          <p>通过 GitCode Issues 参与讨论</p>
        </div>
        <div class="footer-section">
          <h3>友情链接</h3>
          <NSpace vertical>
            <NButton text tag="a" href="https://cangjie-lang.cn" target="_blank">仓颉语言官网</NButton>
          </NSpace>
        </div>
      </div>
      <NDivider />
      <div class="footer-bottom">
        <p style="color: rgba(255, 255, 255, 0.75);">&copy; {{ new Date().getFullYear() }} {{ store.organization.name }}. All rights reserved.</p>
        <p class="beian">
          <NButton 
            text 
            tag="a" 
            href="https://beian.miit.gov.cn" 
            target="_blank"
            :style="{
              color: 'rgba(255, 255, 255, 0.75)',
              fontSize: '0.9rem'
            }">
            粤ICP备16095614号
          </NButton>
        </p>
      </div>
    </footer>
  </div>
</template>

<style scoped>
.app-container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: rgba(18, 18, 18, 0.9);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.nav-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logo-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
}

.logo h1 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.95);
}

.nav-links {
  display: flex;
  gap: 1.5rem;
  align-items: center;
}

.nav-links a {
  color: rgba(255, 255, 255, 0.75);
  text-decoration: none;
  font-weight: 500;
  transition: all 0.3s ease;
  position: relative;
  padding: 0.5rem 0;
}

.nav-links a::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 2px;
  background: #7b82ff;
  transform: scaleX(0);
  transform-origin: right;
  transition: transform 0.3s ease;
}

.nav-links a:hover,
.nav-links a.router-link-exact-active {
  color: #7b82ff;
}

.nav-links a:hover::after,
.nav-links a.router-link-exact-active::after {
  transform: scaleX(1);
  transform-origin: left;
}

.mobile-menu-button {
  display: none;
}

.mobile-menu-overlay {
  display: none;
}

footer {
  margin-top: auto;
  background: rgba(18, 18, 18, 0.9);
  backdrop-filter: blur(10px);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding: 3rem 1rem 1rem;
}

.footer-content {
  max-width: 1200px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 2rem;
  margin-bottom: 2rem;
}

.footer-section h3 {
  color: rgba(255, 255, 255, 0.95);
  font-size: 1.2rem;
  margin-bottom: 1rem;
}

.footer-section p {
  color: rgba(255, 255, 255, 0.6);
  margin: 0;
}

.footer-section a {
  color: rgba(255, 255, 255, 0.6);
  text-decoration: none;
  transition: color 0.3s ease;
}

.footer-section a:hover {
  color: #7b82ff;
}

.footer-bottom {
  max-width: 1200px;
  margin: 0 auto;
  padding-top: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: rgba(255, 255, 255, 0.5);
  font-size: 0.9rem;
}

@media (max-width: 768px) {
  .mobile-menu-button {
    display: block;
    cursor: pointer;
    z-index: 102;
  }

  .hamburger {
    width: 24px;
    height: 20px;
    position: relative;
  }

  .hamburger span {
    display: block;
    position: absolute;
    height: 2px;
    width: 100%;
    background: rgba(255, 255, 255, 0.85);
    border-radius: 2px;
    transition: all 0.3s ease;
  }

  .hamburger span:nth-child(1) {
    top: 0;
  }

  .hamburger span:nth-child(2) {
    top: 9px;
  }

  .hamburger span:nth-child(3) {
    bottom: 0;
  }

  .hamburger.is-active span:nth-child(1) {
    transform: rotate(45deg);
    top: 9px;
  }

  .hamburger.is-active span:nth-child(2) {
    opacity: 0;
  }

  .hamburger.is-active span:nth-child(3) {
    transform: rotate(-45deg);
    bottom: 9px;
  }

  .nav-links {
    position: fixed;
    top: 0;
    right: -100%;
    height: 100vh;
    width: 80%;
    max-width: 300px;
    background: rgba(18, 18, 18, 0.98);
    backdrop-filter: blur(10px);
    flex-direction: column;
    padding: 5rem 2rem;
    transition: right 0.3s ease;
    z-index: 101;
  }

  .nav-links.mobile-active {
    right: 0;
  }

  .mobile-menu-overlay {
    display: block;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 100;
  }

  .footer-bottom {
    flex-direction: column;
    text-align: center;
    gap: 0.5rem;
  }
}
</style> 